package Operations;

import Book.BookList;

import java.util.Scanner;

public class BorrowOperation implements Operation{

    @Override
    public void operation(BookList bookList) {

        Scanner scanner = new Scanner(System.in);

        int currentSize = bookList.getUsedSize();//存储当前书的数目

        System.out.println("借阅图书");

        System.out.println("输入要借阅的图书");

        String name = scanner.nextLine();

        for (int i = 0; i < currentSize; i++) {//判断有没有名字相同的书
            if (name .equals(bookList.getBooks()[i].getName())) {
                bookList.getBooks()[i].setBorrowed(true);
                System.out.println("借阅成功");
                new ShowOperation().operation(bookList);
                return;
            }
        }

        System.out.println("没找到该本书");

    }
}
